--[[/**
-- * 
 * 改变能量，溢出则增加buff
 *
 * @author heyang
-- *
-- */]]

---@class BuffEffect352101 : BaseBuffEffect
BuffEffect352101 = ClientFight.CreateClass("BuffEffect352101", ClientFight.BaseBuffEffect)
local t = BuffEffect352101

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local fighter = buff.target;
    local skill = buff.addParameters[2];
    local centrePos = skill.target.position;
    local targetPos = buff.target.position;
    local distance = DistanceUtil.countDistance(centrePos, targetPos);

    if (distance < 0.5) then
    return super.action(fight, buff, parameters);
    end
    -- 每次触发往中心点移动的距离a
    local move = buff.buffBean.f_BuffEffectValue[1] * 1 / 10000;
    local x = 0;
    local y = 0;
    if (distance > move) then
    --double x = skillPos.x - targetPos.x;
    --double y = skillPos.y - targetPos.y;
    --double movedx = x * move / distance;
    --double movedy = y * move / distance;
    local movedPos = MathUtil.getMovedVectorByLen(targetPos, centrePos, move);

    x = movedPos.x;
    y = movedPos.y;
     else 
    x = centrePos.x;
    y = centrePos.y;
    end
    FighterManager.changePosition(fight, buff.target, 0, x, y, 0, true, true, true);
    local logPos = targetPos;
    SkillRoleMgr.savePathFile("[" + fight.frame + "][EFFECT]Fighter " + buff.target.fighterId + " Buff"
    + buff.modelId + " 往中心点移动1次(" + logPos + ")");
    -- 检查是否出界
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()